<?=$this->header()?>


    <?=$this->menu("galleries")?>


    <h1><?=$this->message("label.header", _Gallery::BUNDLE)?></h1>


    <? /* Breadcrums route & user info display */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.header", _Gallery::BUNDLE),
                "href"=>"gallery/index"
            ),
            array(
                "name"=>$this->message("label.images.for", _Gallery::BUNDLE) . " \"" . $this->galleryImages($this->imageListForm)->getGallery()->getName() ."\""
            )
        ),                                                     // Route display
        $this->imageListForm,                                  // ListForm (for user info, see float right)
        $this->galleryImages($this->imageListForm)->getRows()) // The total amount of images
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->imageListForm)?>"
          method="post"
          action="gallery/image/index"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "gallery/image/edit?galleryImage->galleryId=" . $this->imageListForm->getId(), // Add new URL
            $this->imageListForm, // ListForm
            array(                // Filter fields
                GalleryImagePeer::CAPTION=>"Caption",
                BinaryFilePeer::FILE_NAME=>"Filename",
                GalleryImagePeer::MODIFIED_DATE=>$this->message("choose.modified", _Core::BUNDLE),
                GalleryImagePeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                GalleryPeer::ACTIVE=>$this->message("choose.active", _Core::BUNDLE),
            ),
            false // No languages for this page.
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th class="narrow"><?=$this->message("prompt.image", _Gallery::BUNDLE)?></th>
            <th>
                <?=$this->TH(
                    $this->imageListForm,      // ListForm
                    GalleryImagePeer::CAPTION, // Sort Field
                    $this->message("prompt.caption", _Gallery::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->imageListForm,                           // ListForm
                    BinaryFilePeer::URI,                            // Sort Field
                    $this->message("label.filename", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->imageListForm,                          // ListForm
                    GalleryImagePeer::MODIFIED_DATE,               // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->imageListForm,                         // ListForm
                    GalleryImagePeer::INSERT_DATE,                // Sort Field
                    $this->message("choose.created", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->imageListForm,                       // ListForm
                    GalleryImagePeer::ACTIVE,                   // Sort Field
                    $this->message("label.active", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.order", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->imageListForm,                         // ListForm
                    GalleryImagePeer::POSITION,                   // Sort Field
                    $this->message("label.order", _Core::BUNDLE), // Header Name
                    "ASC"
                )?>
            </th>
            <th class="buttons"></th>
        </tr>

        <? foreach($this->galleryImages($this->imageListForm)->getItems() as $image) { ?>

            <? /* Display the default language gallery */ ?>
            <tr class="ctrl">
                <td class="checkbox">

                    <input type="checkbox"
                           name="items[]"
                           value="<?=$image->getGalleryImageId()?>"
                           <?=in_array($image->getGalleryImageId(), $this->imageListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td>
                    <a title="<?=$this->message("title.image", _Core::BUNDLE)?>" href="image/<?=$image->getImageRelatedByImageId()->getBinaryFile()->getUri()?>">
                        <?=$this->thumbnail($image->getThumbnailId())?>
                    </a>
                </td>
                <td><?=nl2br($this->truncateNicely($image->getCaption(), 14, 18, "..."))?></td>
                <td><?=$this->truncateNicely($image->getImageRelatedByImageId()->getBinaryFile()->getUri(), 10, 20, "...")?></td>
                <td class="buttons" title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$image->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                    <?=$image->getModifiedDate(_Core::FORMAT_DATE)?>
                </td>
                <td class="buttons" title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$image->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$image->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                    <?=$this->message("label." . ($image->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                </td>
                <td title="<?=$this->message("title.move", _Core::BUNDLE)?>">

                    <? if($image->getPosition() > 1): ?>
                        <input type="image" onclick="moveup(<?=$image->getGalleryImageId()?>, this.form)"
                               src="static.php?file=<?=$this->image("cms/core/view/gfx/arrow_up.png")?>" alt=""
                               alt="<?=$this->message("title.move.up", _Core::BUNDLE)?>"
                               title="<?=$this->message("title.move.up", _Core::BUNDLE)?>. <?=$this->message("title.move", _Core::BUNDLE)?>" />
                    <? endif; ?>

                    <? if($image->getPosition() < $image->getMaxPosition()): ?>
                        <input type="image" onclick="movedown(<?=$image->getGalleryImageId()?>, this.form)"
                               src="static.php?file=<?=$this->image("cms/core/view/gfx/arrow_down.png")?>"
                               alt="<?=$this->message("title.move.down", _Core::BUNDLE)?>"
                               title="<?=$this->message("title.move.down", _Core::BUNDLE)?>. <?=$this->message("title.move", _Core::BUNDLE)?>" />
                    <? endif; ?>

                </td>
                <td class="buttons">

                    <input type="button"
                           onclick="to('gallery/image/edit?galleryImage->galleryImageId=<?=$image->getGalleryImageId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$image->getGalleryImageId()?>, '<?=get_class($this->imageListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                </td>
            </tr>

        <? } ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->imageListForm, // ListForm
            array(                // The actions
                "activate"=>$this->message("choose.activate", _Core::BUNDLE),
                "deactivate"=>$this->message("choose.deactivate", _Core::BUNDLE),
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->imageListForm,                                                          // ListForm
            "gallery/image/edit?galleryImage->galleryId=" . $this->imageListForm->getId(), // Add new URL
            $this->galleryImages($this->imageListForm)->getRows()                          // The total amount of users
        )?>


    </form>

<?=$this->footer()?>